<template>
	<view class="content">
		<view class="top-wrap"></view>
		<view class="wrap">
			<view class="" style="width: 100%;text-align: center;">
				<image src="../../static/log.png" style="width: 127rpx;height: 127rpx;"></image>
				<view style="color: #CAA153;font-size: 50rpx;margin-top: 20rpx;">开心小圈</view>
			</view>
			<view class="button">
				<view v-if="brand != 'vivo' && brand != 'oppo'" class="gyg" @click="guangyiguang()">逛一逛</view>
				<button class="new-btn login-btn" @click="nav('login')">开启约会</button>				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				xieyi: true,
				platform:'',
				brand:uni.getStorageSync('brand')?uni.getStorageSync('brand'):'0'
			}
		},
		onLoad() {
			// #ifdef MP-WEIXIN
			  this.platform='devtools'
			// #endif
		},
		methods: {
			//逛一逛
			guangyiguang(){
				uni.navigateTo({
					url:"/pages/guangyiguang/sex"
				})
			},
			nav(text){
				let that = this
				let res = '';
				if(that.platform == "devtools"){
					return new Promise(async resolve =>{
						uni.login({
							provider: 'weixin',
							async success(loginRes) {
								console.log('小程序');
								const {data: resa} = await that.$Request({
									url: 'apis/home/user/getopenid',
									data: {
										code: loginRes.code
									}
								})
								res = resa;
								uni.setStorage({key: 'openid',data: res.openid}) 
								// console.log(uni.getSystemInfoSync().platform);
								console.log("openid是什么")
								console.log(res)
								if(!res.data){
									console.log('没有data');
									uni.navigateTo({
										url:"/pages/register/index"
									})
								}
								
								if(res.data){
									that.$store.state.hasLogin = true
									that.$store.state.userinfo = res.data
									that.$store.state.sex = res.data.sex
									that.$store.state.isVip = res.data.is_vip
									that.$store.state.userid = res.data.id
									uni.setStorage({key: 'uid',data: res.data.id})
									uni.setStorage({key: 'sex',data: res.data.sex})
									uni.setStorage({key: 'isVip',data: res.data.is_vip})
									// uni.setStorage({key: 'rz',data: res.data.is_identity_authentication})
									console.log(res.data.id)
									uni.setStorage({key: 'pay_authentication', data: res.data.pay_authentication})
									console.log('==='+res.data.pay_authentication);
									if(res.data.pay_authentication == 0){
										uni.navigateTo({
											url:"/pages/appview/authentication"
										})
									}else{
										uni.switchTab({
											url:"/pages/index/index"
										})
									}
								}
							}
						})
					})
				}else{
					uni.navigateTo({
						url:"/pages/login/oneClickLogin"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100vh;
		// display: flex;
		flex-direction: column;
		position: relative;
		/* 上方滚动 */
		.top-wrap {
			background-image: url('https://z3.ax1x.com/2021/07/20/WtaMtK.jpg');
			background-size: 100%;
			/* background-color: #d800ff; */
			padding: 0;
			width: 100vw;
			-webkit-animation: slideop 30s linear infinite;
			animation: slideop 30s linear infinite;
			background-position: 0 bottom;
			width: 100vw;
			height: 100vh;
		}
		
		@keyframes slideop {
			0% {
				background-position: 0;
			}
		
			100% {
				background-position: 0 bottom;
			}
		}
		
		.wrap {
			padding: 10px;
			background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 1));
			position: absolute;
			width: 100%;
			bottom: 0;
			box-shadow: 10px 10px 30px 50px rgba(0, 0, 0, 0.5);
			.title {
				margin: 20rpx 30rpx;
				color: #fff;
				font-size: 25px;
				font-weight: bold;
			}

			.text {
				margin: 0rpx 30rpx;
				text{
					margin-right: 10px;
					color: #fff;
				}
			}
			
			.new-btn {
				background: linear-gradient(to right, #d9a14e, #b57e2c);
				color: #fff;
				font-size: 32rpx;
				font-weight: bold;
				line-height: 90rpx;
				width: 60%;
				margin: 60rpx auto;
				border-radius: 60rpx;
			}
			.check-box {
				border: 1px solid #ddd;
				width: 20px;
				height: 20px;
				margin-right: 5px;
			}

			.check-box.active {
				background-size: 100% 100%;
				background-repeat: no-repeat;
			}
			.xieyi {
				color: #fff;
				text{
					color: #fff;
				}
			}
		}
	}
	.button{
		display: flex;
		.gyg {
			border: 2px solid #fff;
			border-radius: 60rpx;
			color: #fff;
			width: 30%;
			font-size: 32rpx;
			font-weight: bold;
			line-height: 90rpx;
			margin: 60rpx auto;
			text-align: center;
		}
	}
	
</style>
